<?php
/**
 * Eka Framework 0.3.0
 *
 * @copyright Copyright (c) 2008 Alexey Yu. Chuprina <656b61@gmail.com> (http://php-eka.googlecode.com)
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 *
 * @version $Id$
 */

/**
 * Eka_Db_Statement_Abstract
 *
 * @package Db
 * @subpackage Statement
 */
abstract class Eka_Db_Statement_Abstract
{

	/**
	 * @var Eka_Db_Adapter_Abstract
	 */
	protected $adapter = null;
	
	protected $lastBind = null;
	
	/**
	 * Constructor
	 *
	 * @param Eka_Db_Adapter_Abstract $adapter
	 * @param string $sql
	 */
	public function __construct($adapter, $sql)
	{
		$this->adapter = $adapter;
		$this->prepare($sql);
	}

	/**
	 * Executes a prepared statement
	 *
	 * @param array $bind
	 * @return bool
	 */
	abstract public function execute(array $bind = null);
	
	/**
	 * Fetches a row from the result set as an array indexed by both column name and 0-indexed column number
	 *
	 * @return array
	 */
	abstract public function fetch();
	
	/**
	 * Fetches a row from the result set as an array indexed by column name
	 *
	 * @return array
	 */
	abstract public function fetchAssoc();
	
	/**
	 * Fetches a row from the result set as an array indexed by column number, starting at column 0
	 *
	 * @return array
	 */
	abstract public function fetchNum();
	
	/**
	 * Returns a single column from the next row of a result set
	 *
	 * @param int $col Position of the column to fetch
	 * @return string
	 */
	abstract public function fetchColumn($pos = 0);
	
	/**
	 * Returns all rows from the result set as an array indexed by both column name and 0-indexed column number
	 *
	 * @return array Collection of rows
	 */
	abstract public function fetchAll();
	
	/**
	 * Returns all rows from the result set as an array indexed by column name
	 *
	 * @return array Collection of rows
	 */
	abstract public function fetchAllAssoc();
	
	/**
	 * Returns all rows from the result set as an array indexed by column number, starting at column 0
	 *
	 * @return array Collection of rows
	 */
	abstract public function fetchAllNum();
	
	/**
	 * @param int $col Position of the column to fetch
	 * @return array Collection of columns
	 */
	abstract public function fetchAllColumn($pos = 0);
	
	/**
	 * Returns the number of rows affected by the execution
	 *
	 * @return int
	 * @throws Eka_Db_Statement_Exception
	 */
	abstract public function rowCount();
	
	#TODO! дописать методы
}